package listbyorder.access301_400.test371;

public class Solution1 {

    // 不用加减号计算两个数的和
    public int getSum(int a, int b) {
        if (a == 0) return b;
        if (b == 0) return a;
        int lower;    // 低位
        int carrier;  // 进位
        while (true) {
            lower = a ^ b;
            carrier = a & b;
            if (carrier == 0) break;
            a = lower;
            b = carrier << 1;
        }
        return lower;
    }
}
